package main

import (
	"flag"
	"fmt"
)

func main() {
	// 定义几个变量 用于接收命令行参数值
	var user string
	var pwd string
	var host string
	var port string

	flag.StringVar(&user, "u", "", "用户名，默认为空")
	flag.StringVar(&pwd, "pwd", "", "密码，默认为空")
	flag.StringVar(&host, "host", "localhost", "主机名，默认为localhost")
	flag.StringVar(&port, "port", "3306", "端口，默认为3306")

	// 转换操作，必须调用
	flag.Parse()
	fmt.Printf("user=%v pwd=%v host=%v port=%v",
		user, pwd, host, port)
}
